<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<!DOCTYPE html>
<html>
 <head>
  <title>设备信息</title>
  <t:base type="jquery,easyui,tools,DatePicker"></t:base>
 </head>
 <body>
	<t:formvalid formid="formobj" dialog="true" usePlugin="password" layout="table" action="userDoorAccessController.do?doUpdate" tiptype="3" beforeSubmit="validForm()">
  		<input type="hidden" name="id" value="${obj.id }"/>
  		<table style=" " cellpadding="0" cellspacing="1" class="formtable">
				<tr>
					<td align="right">
						<label class="Validform_label">
							授权类型:
						</label>
					</td>
					<td class="value">
					     	<t:enumSelect field="accessRightValue" type="radio" defaultVal="${obj.accessRight.value }" 
								  hasLabel="false"  enumClass="com.mengtian_tech.smart_lab.entity.doorAccess.AccessRight"
								  title="授权类型">
							</t:enumSelect>     
							<span class="Validform_checktip"></span>
							<label class="Validform_label" style="display: none;">授权类型</label>
					</td>
				</tr>
				<tr id="start" style="display: none;">
					<td align="right">
						<label class="Validform_label">
							开始时间:
						</label>
					</td>
					<td class="value">
						<input id="startTime" name="startTime" type="text"  maxlength="80"
					     	 style="width: 150px" class="inputxt" value='<fmt:formatDate value="${obj.startDate }" pattern="yyyy-MM-dd HH:mm"/>'>
						<span class="Validform_checktip"></span>
						<label class="Validform_label" style="display: none;">开始时间</label>
					</td>
				</tr>
				<tr id="end" style="display: none;">
					<td align="right">
						<label class="Validform_label">
							结束时间:
						</label>
					</td>
					<td class="value">
						<input id="endTime" name="endTime" type="text"  maxlength="80"
					     	 style="width: 150px" class="inputxt" value='<fmt:formatDate value="${obj.endDate }" pattern="yyyy-MM-dd HH:mm"/>'>	
						<span class="Validform_checktip"></span>
						<label class="Validform_label" style="display: none;">结束时间</label>
					</td>
				</tr>
				<tr>
					<td align="right">
						<label class="Validform_label">
							门禁:
						</label>
					</td>
					<td class="value"> 
                	     <input id="doorAccessId" name="doorAccessId" type="hidden" value="${obj.doorAccess.id }"/>               
					     <input id="doorAccessName"  type="text" style="width: 150px" class="inputxt" readonly="readonly" datatype="*" value="${obj.doorAccess.name }"/>
					     <t:choose textname="name" inputTextname="doorAccessName" hiddenName="doorAccessId" hiddenid="id" url="doorAccessController.do?goSelect" name="list"
                          icon="icon-search" title="选择门禁"  isclear="false" isInit="true" width="470px">
                         </t:choose>
						<span class="Validform_checktip"></span>
						<label class="Validform_label" style="display: none;">门禁</label>						
					</td>
				</tr>	
			</table>
	</t:formvalid>
<script>
	$("#startTime").attr("class","Wdate").click(function(){WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'});});
	$("#endTime").attr("class","Wdate").click(function(){WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'});});
	$(function(){
		if($("[name='accessRightValue']:checked").val()=='1'){
			$("#start").show();
			$("#end").show();
			$("#startTime").attr('dataType',"*");
			$("#endTime").attr('dataType',"*");
		}
	
		$("[name='accessRightValue']").on('click', function(){
			if($(this).val()=='0'){
				$("#start").hide();
				$("#end").hide();
				$("#startTime").attr('dataType',"");
				$("#startTime").removeAttr('dataType');
				$("#endTime").removeAttr('dataType');
			}else{
				$("#start").show();
				$("#end").show();
				$("#startTime").attr('dataType',"*");
				$("#endTime").attr('dataType',"*");
			}
		});
	});
	function validForm(){
		if($("[name='accessRightValue']:checked").val()!='1'){
  			$("#startTime").val('');
			$("#endTime").val('');
  		}else{
  			if($("#startTime").val()>$("#endTime").val()){
  				tip('开始时间不能晚于结束时间');			
	  			return false;
  			}
  		}
	}
</script>
 </body>
</html>